﻿<UserControl
    x:Class="mPassRT.Controls.DatabaseKeyControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    
    <UserControl.Resources>
        <Style x:Key="CommonKeyControlStyle" TargetType="FrameworkElement">
            <Setter Property="Margin" Value="10"/>
        </Style>
        <Style x:Key="TextStyle" BasedOn="{StaticResource CommonKeyControlStyle}" TargetType="TextBlock">
            <Setter Property="FontFamily" Value="Segoe UI"/>
            <Setter Property="FontSize" Value="14.667"/>
        </Style>
        <Style x:Key="ButtonStyle" BasedOn="{StaticResource CommonKeyControlStyle}" TargetType="FrameworkElement">
            <Setter Property="MinWidth" Value="100"/>
        </Style>
    </UserControl.Resources>

    <Grid HorizontalAlignment="Stretch" Background="Gray" VerticalAlignment="Center">
        <Grid VerticalAlignment="Center" HorizontalAlignment="Center" Margin="20">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="600"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>

            <TextBlock Style="{StaticResource SubheaderTextStyle}" HorizontalAlignment="Center" Grid.Row="0" Grid.ColumnSpan="3" Text="{Binding Title}" Margin="0,0,0,20"/>

            <TextBlock Style="{StaticResource TextStyle}" Grid.Row="1" Grid.Column="0">Master Password</TextBlock>
            <PasswordBox Style="{StaticResource CommonKeyControlStyle}" Password="{Binding Password, Mode=TwoWay}" Grid.Row="1" Grid.Column="1" IsPasswordRevealButtonEnabled="True"></PasswordBox>

            <TextBlock Style="{StaticResource TextStyle}" Grid.Row="2" Grid.Column="0">Key File</TextBlock>
            <TextBox Style="{StaticResource CommonKeyControlStyle}" Text="{Binding KeyFile.Path}" IsReadOnly="True" Grid.Row="2" Grid.Column="1"></TextBox>
            <Button Style="{StaticResource ButtonStyle}" Command="{Binding BrowseCommand}" Grid.Row="2" Grid.Column="2">Browse...</Button>

            <StackPanel Grid.Row="3" Grid.ColumnSpan="3" Orientation="Horizontal" HorizontalAlignment="Center">
                <Button Style="{StaticResource ButtonStyle}" Command="{Binding CommitCommand}" Content="{Binding CommitButtonText}"/>
                <Button Style="{StaticResource ButtonStyle}" Command="{Binding CancelCommand}">Cancel</Button>
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>
